<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Image List</title>
    <style>
        .image-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }
        .image-item {
            width: 95%;
            margin: 10px;
        }
    </style>
</head>
<body>
    <div class="image-list" id="imageList"></div>

    <script>
        var etfs = [
            {"name": "中证红利", "code":"SH515080"},
            {"name": "黄金ETF", "code":"SZ159934"},
            {"name": "食品饮料", "code":"SH515170"},
            {"name": "医疗ETF", "code":"SH512170"},
            {"name": "中药ETF", "code":"sh562390"},
            {"name": "创新药ETF", "code":"SH515120"},
            {"name": "新材料ETF", "code":"SH516360"},
            {"name": "白酒", "code":"SZ399997"},
            {"name": "空天军工", "code":"SH512660"},
            {"name": "恒生科技", "code":"sh513260"},
            {"name": "软件ETF", "code":"SH515230"},
            {"name": "游戏动漫", "code":"sh516770"},
            {"name": "大数据ETF", "code":"SH515400"},
            {"name": "半导体芯片", "code":"SH516350"},
            {"name": "5G通信", "code":"sh515050"},
            {"name": "光伏", "code":"sh515790"},
            {"name": "电池50", "code":"SZ159796"},
            {"name": "汽车", "code":"SH516110"},
            {"name": "AI人工智能", "code":"sh515070"},
            {"name":"稀有金属ETF", "code":"SH562800"},
            {"name": "煤炭等权LOF", "code":"SZ161724"},
            {"name": "养殖ETF", "code":"SZ159865"},
            {"name": "豆粕ETF", "code":"sz159985"},
        ]

        // 示例图片 URL 数组
        var imageUrls = [];

        for(var i=0; i<etfs.length; i++) {
            etf = etfs[i]
            let flag = etf['code'].toLowerCase().startsWith('sh') ? '1' : '0';
            let nid = `${flag}.${etf['code'].slice(2)}`;
            url = "https://webquoteklinepic.eastmoney.com/GetPic.aspx?nid="+nid+"&type=&unitWidth=-6&ef=EXTENDED_BOLL&formula=MACD&AT=1&imageType=KXL"
            imageUrls.push(url)
            console.log(url)
        }


        // 获取图片列表容器元素
        var imageList = document.getElementById("imageList");

        // 遍历图片 URL 数组，创建图片元素并添加到列表中
        imageUrls.forEach(function(url) {
            var img = document.createElement("img");
            img.src = url;
            img.classList.add("image-item");
            imageList.appendChild(img);
        });
    </script>
</body>
</html>